package edu.zut.cs.software.cms.admin.domain;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import edu.zut.cs.software.cms.base.domain.BaseTreeEntity;
import java.util.List;

@Entity
@Table(name = "T_ADMIN_CATEGORY")
@NamedQueries({ @NamedQuery(name = "AdminCategory.getRoot", query = "select m from AdminCategory m where m.parent is null") })
public class AdminCategory extends BaseTreeEntity<AdminCategory, Long>{
	private static final long serialVersionUID = -3199029100807028476L;
	
	@Column
	String code;
	
	@Column
	String name;
	
	@OneToMany(mappedBy = "adminCategory", cascade = CascadeType.REMOVE, fetch = FetchType.EAGER)
	List<Admin> admins;

	/**
	 * @return the code
	 */
	public String getCode() {
		return code;
	}

	/**
	 * @param code the code to set
	 */
	public void setCode(String code) {
		this.code = code;
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

}